home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Tools & Apps / Graphics & Imaging / SLUDGE 2.0 / Source Code / Parasite.a < prev    next >
Encoding:
Text File  |  1990-09-14  |  19.0 KB  |  359 lines  |  [TEXT/MPS ]

  1. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  2. ;•                                                                           •
  3. ;•   File Name:   Parasite.a                                                 •
  4. ;•   ----------                                                              •
  5. ;•                                                                           •
  6. ;•   Copyright © 1989 Apple Computer, Inc.  All Rights Reserved              •
  7. ;•                                                                           •
  8. ;•       Description                                                         •
  9. ;•       -----------                                                         •
  10. ;•       This file contains the assembly language routines of the SLUDGE     •
  11. ;•         parasite.                                                             •
  12. ;•                                                                           •
  13. ;•       History                                                             •
  14. ;•       -------                                                             •
  15. ;•                                                                           •
  16. ;•       Author          Date            Description                         •
  17. ;•       ------------------------------------------------------------------  •
  18. ;•       Kevin McEntee   2/20/90         Original Implementation             •
  19. ;•                                                                           •
  20. ;•                                                                           •
  21. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  22.  
  23.  
  24.                         INCLUDE                'traps.a'
  25.                         INCLUDE                'ToolEqu.a'
  26.                         EXPORT                ATRAP_EX:CODE
  27.                         EXPORT                TAKE_A_TRAP_EXCEPTION_VECTOR:CODE
  28.                         EXPORT                TAKE_JUMP_TRACE_VECTOR:CODE
  29.                         IMPORT                HLL_ATRAP_EX:CODE
  30.                         EXPORT                MASTER_A_TRAP:CODE
  31.                         EXPORT                GET_MASTER_A_TRAP_HANDLE:CODE
  32.                         EXPORT                GET_SAVED_A_TRAP_VECTOR:CODE
  33.                         EXPORT                SET_JUMP_TRACE_BIT:CODE
  34.                         EXPORT                CLEAR_JUMP_TRACE_BIT:CODE
  35.                         SEG                    'NUGG'
  36.  
  37.  
  38. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  39. ;•                                                                           •
  40. ;•   Identifier:    MASTER_SLUDGE                                             •
  41. ;•   -----------                                                             •
  42. ;•                                                                           •
  43. ;•       Description                                                         •
  44. ;•       -----------                                                         •
  45. ;•       This function is never executed.  It is a place for a DC.L that     •
  46. ;•         contains the current SLUDGE factor.  There are access routines for  •
  47. ;•         this DC.L later in this file.                                         •
  48. ;•                                                                           •
  49. ;•       History                                                             •
  50. ;•       -------                                                             •
  51. ;•                                                                           •
  52. ;•       Author          Date            Description                         •
  53. ;•       ------------------------------------------------------------------  •
  54. ;•       Kevin McEntee   2/20/90         Original Implementation             •
  55. ;•                                                                           •
  56. ;•                                                                           •
  57. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  58. MASTER_SLUDGE            PROC
  59.                         Jmp                    skipper
  60.                         DC.L                0
  61. skipper                    Pea                    #'How dare you disturb the sludge MASTER! Use the g command NOW!'
  62.                         _DebugStr
  63.                         RTS
  64.                         ENDPROC
  65.                         
  66.                         
  67.  
  68.  
  69. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  70. ;•                                                                           •
  71. ;•   Identifier:    GET_SAVED_SLUDGE_FACTOR                                  •
  72. ;•   -----------                                                             •
  73. ;•                                                                           •
  74. ;•       Description                                                         •
  75. ;•       -----------                                                         •
  76. ;•       This function returns the current SLUDGE factor in register D0.     •
  77. ;•                                                                           •
  78. ;•       History                                                             •
  79. ;•       -------                                                             •
  80. ;•                                                                           •
  81. ;•       Author          Date            Description                         •
  82. ;•       ------------------------------------------------------------------  •
  83. ;•       Kevin McEntee   2/20/90         Original Implementation             •
  84. ;•                                                                           •
  85. ;•                                                                           •
  86. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  87. GET_SAVED_SLUDGE_FACTOR        PROC
  88.                             Move.L                A0,-(A7)
  89.                             Lea                    MASTER_SLUDGE,A0
  90.                             AddQ.L                #4,A0
  91.                             Move.L                (A0),D0
  92.                             Move.L                (A7)+,A0
  93.                             RTS
  94.                             ENDPROC
  95.                             
  96.                             
  97. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  98. ;•                                                                           •
  99. ;•   Identifier:    ATRAP_EX                                                 •
  100. ;•   -----------                                                             •
  101. ;•                                                                           •
  102. ;•       Description                                                         •
  103. ;•       -----------                                                         •
  104. ;•       This proc is executed at each a-trap exception.  SLUDGE needs          •
  105. ;•         control here because the exception turns off the jump-trace bit     •
  106. ;•         and SLUDGE needs to turn it back on.  So SLUDGE turns it back on    •
  107. ;•         and jumps to the system a-trap dispatcher.                             •
  108. ;•                                                                           •
  109. ;•       History                                                             •
  110. ;•       -------                                                             •
  111. ;•                                                                           •
  112. ;•       Author          Date            Description                         •
  113. ;•       ------------------------------------------------------------------  •
  114. ;•       Kevin McEntee   2/20/90         Original Implementation             •
  115. ;•                                                                           •
  116. ;•                                                                           •
  117. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  118. ATRAP_EX                PROC
  119.                         Pea                    #0
  120.                         MoveM.L                A0-A7/D0-D7,-(A7)
  121.                         Link                A6,#0
  122.                         Move.L                A6,-(SP)
  123.                         Pea                    72(A6)            ; pass the address of the stack frame
  124.                         Move.L                A0,-(A7)
  125.                         Jsr                    HLL_ATRAP_EX
  126.                         MoveA.L                8(SP),A6
  127.                         Move.L                D0,68(A6)        ;  the address of the system a-trap dispatcher will be on the top of the stack
  128.                         Unlk                A6
  129.                         MoveM.L                (A7)+,A0-A7/D0-D7
  130.                         Ori.W                #$4000,SR        ;  set jump trace bit
  131.                         RTS
  132.                         ENDPROC
  133.                         
  134.                         
  135. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  136. ;•                                                                           •
  137. ;•   Identifier:    JTRACE_EX                                                 •
  138. ;•   -----------                                                             •
  139. ;•                                                                           •
  140. ;•       Description                                                         •
  141. ;•       -----------                                                         •
  142. ;•       This proc is executed at each jump trace exception.  It simply      •
  143. ;•         executes a tight loop the number of times specified by the current  •
  144. ;•         SLUDGE factor.                                                         •
  145. ;•                                                                           •
  146. ;•       History                                                             •
  147. ;•       -------                                                             •
  148. ;•                                                                           •
  149. ;•       Author          Date            Description                         •
  150. ;•       ------------------------------------------------------------------  •
  151. ;•       Kevin McEntee   2/20/90         Original Implementation             •
  152. ;•                                                                           •
  153. ;•                                                                           •
  154. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  155. JTRACE_EX                PROC
  156.                         Move.L                D0,-(A7)
  157.                         JSR                    GET_SAVED_SLUDGE_FACTOR
  158. back                    DBF                    D0,back                            ; loop here
  159.                         Move.L                (A7)+,D0
  160.                         OrI.W                #$4000,(A7)        ; set jump trace bit in stacked status register
  161.                         RTE
  162.                         ENDPROC
  163. ;••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  164. ;•                                                                                            •
  165. ;•            Function Name                                                                    •
  166. ;•            -------------                                                                    •
  167. ;•            TAKE_A_TRAP_EXCEPTION_VECTOR                                                    •
  168. ;•                                                                                            •
  169. ;•            Purpose                                                                            •
  170. ;•            -------                                                                            •
  171. ;•            This PROC will replace the a-trap exception vector with address of the             •
  172. ;•            ATRAP_EX PROC                                                                    •
  173. ;•                                                                                            •
  174. ;•                                                                                            •
  175. ;•            Modification History                                                            •
  176. ;•            --------------------                                                            •
  177. ;•                                                                                            •
  178. ;•            Name                    Date        Change                                        •
  179. ;•            ----                    ----        ------                                        •
  180. ;•            Kevin McEntee            9/21/88        Original implementation                        •
  181. ;•                                                                                            •
  182. ;••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  183. TAKE_A_TRAP_EXCEPTION_VECTOR            PROC
  184.                                         Move.L            A0,-(A7)
  185.                                         Move.L            A1,-(A7)
  186.                                         MoveA.L            #$28,A0            ; A0 -> A-trap exception vector
  187.                                         Lea                ATRAP_EX,A1        ; A1 -> my exception handler
  188.                                         Move.L            A1,(A0)            ; replace existing exception vector
  189.                                         MoveA.L            (A7)+,A1
  190.                                         MoveA.L            (A7)+,A0
  191.                                         RTS
  192.                                         ENDPROC
  193.                                         
  194. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  195. ;•                                                                           •
  196. ;•   Identifier:    TAKE_JUMP_TRACE_VECTOR                                     •
  197. ;•   -----------                                                             •
  198. ;•                                                                           •
  199. ;•       Description                                                         •
  200. ;•       -----------                                                         •
  201. ;•       This proc accepts a SLUDGE factor as a parameter and saves it as      •
  202. ;•         current SLUDGE factor and sets the jump-trace exception vector to   •
  203. ;•         to JTRACE_EX.                                                         •
  204. ;•                                                                           •
  205. ;•       History                                                             •
  206. ;•       -------                                                             •
  207. ;•                                                                           •
  208. ;•       Author          Date            Description                         •
  209. ;•       ------------------------------------------------------------------  •
  210. ;•       Kevin McEntee   2/20/90         Original Implementation             •
  211. ;•                                                                           •
  212. ;•                                                                           •
  213. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  214. TAKE_JUMP_TRACE_VECTOR                    PROC
  215.                                         ;
  216.                                         Move.L            A0,-(A7)
  217.                                         Move.L            A1,-(A7)
  218.                                         Move.L            D0,-(A7)
  219.                                         Lea                MASTER_SLUDGE,A0
  220.                                         AddQ.L            #4,A0
  221.                                         Move.L            16(SP),D0
  222.                                         Move.L            D0,(A0)            ; save current SLUDGE factor
  223.                                         ;
  224.                                         MoveA.L            #$24,A0            ; A0 -> trace exception vector
  225.                                         Lea                JTRACE_EX,A1        ; A1 -> my exception handler
  226.                                         Move.L            A1,(A0)            ; replace existing exception vector
  227.                                         ;
  228.                                         ;                                ; put RA on top of stack
  229.                                         MoveA.L            12(SP),A1
  230.                                         Move.L            A1,16(SP)
  231.                                         ;
  232.                                         Move.L            (A7)+,D0
  233.                                         MoveA.L            (A7)+,A1
  234.                                         MoveA.L            (A7)+,A0
  235.                                         AddA.L            #4,A7
  236.                                         RTS
  237.                                         ENDPROC
  238.                                         
  239.  
  240.  
  241. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  242. ;•                                                                           •
  243. ;•   Identifier:    MASTER_A_TRAP                                             •
  244. ;•   -----------                                                             •
  245. ;•                                                                           •
  246. ;•       Description                                                         •
  247. ;•       -----------                                                         •
  248. ;•       This function is never executed.  It is a place for a DC.L that     •
  249. ;•         contains the system value for the a-trap exception vector.  There   •
  250. ;•         are access routines for this DC.L later in this file.                 •
  251. ;•                                                                           •
  252. ;•       History                                                             •
  253. ;•       -------                                                             •
  254. ;•                                                                           •
  255. ;•       Author          Date            Description                         •
  256. ;•       ------------------------------------------------------------------  •
  257. ;•       Kevin McEntee   2/20/90         Original Implementation             •
  258. ;•                                                                           •
  259. ;•                                                                           •
  260. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  261. MASTER_A_TRAP            PROC
  262.                         Jmp                    around
  263.                         DC.L                0
  264. around                    Pea                    #'How dare you disturb the a_trap MASTER! Use the g command NOW!'
  265.                         _DebugStr
  266.                         RTS
  267.                         ENDPROC
  268.                         
  269.                         
  270. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  271. ;•                                                                           •
  272. ;•   Identifier:    GET_MASTER_A_TRAP_HANDLE                                 •
  273. ;•   -----------                                                             •
  274. ;•                                                                           •
  275. ;•       Description                                                         •
  276. ;•       -----------                                                         •
  277. ;•       This returns the address of the DC.L of the MASTER_A_TRAP in        •
  278. ;•         register D0.                                                         •
  279. ;•                                                                           •
  280. ;•       History                                                             •
  281. ;•       -------                                                             •
  282. ;•                                                                           •
  283. ;•       Author          Date            Description                         •
  284. ;•       ------------------------------------------------------------------  •
  285. ;•       Kevin McEntee   2/20/90         Original Implementation             •
  286. ;•                                                                           •
  287. ;•                                                                           •
  288. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  289. GET_MASTER_A_TRAP_HANDLE        PROC
  290.                                 Move.L                A0,-(A7)
  291.                                 Lea                    MASTER_A_TRAP,A0
  292.                                 Move.L                A0,D0
  293.                                 AddQ.L                #4,D0
  294.                                 Move.L                (A7)+,A0
  295.                                 RTS
  296.                                 ENDPROC
  297.  
  298.  
  299.  
  300. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  301. ;•                                                                           •
  302. ;•   Identifier:    GET_SAVED_A_TRAP_VECTOR                                     •
  303. ;•   -----------                                                             •
  304. ;•                                                                           •
  305. ;•       Description                                                         •
  306. ;•       -----------                                                         •
  307. ;•       This returns the saved a-trap execption vector in register DO.         •
  308. ;•                                                                           •
  309. ;•       History                                                             •
  310. ;•       -------                                                             •
  311. ;•                                                                           •
  312. ;•       Author          Date            Description                         •
  313. ;•       ------------------------------------------------------------------  •
  314. ;•       Kevin McEntee   2/20/90         Original Implementation             •
  315. ;•                                                                           •
  316. ;•                                                                           •
  317. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  318. GET_SAVED_A_TRAP_VECTOR        PROC
  319.                                 Move.L                A0,-(A7)
  320.                                 Lea                    MASTER_A_TRAP,A0
  321.                                 AddQ.L                #4,A0
  322.                                 Move.L                (A0),D0
  323.                                 Move.L                (A7)+,A0
  324.                                 RTS
  325.                                 ENDPROC
  326.  
  327.  
  328.  
  329.  
  330. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••
  331. ;•                                                                           •
  332. ;•   Identifier:    SET_JUMP_TRACE_BIT  and CLEAR_JUMP_TRACE_BIT             •
  333. ;•   -----------                                                             •
  334. ;•                                                                           •
  335. ;•       Description                                                         •
  336. ;•       -----------                                                         •
  337. ;•       These procs set and clear the jump-trace bit of the status register.•
  338. ;•                                                                           •
  339. ;•       History                                                             •
  340. ;•       -------                                                             •
  341. ;•                                                                           •
  342. ;•       Author          Date            Description                         •
  343. ;•       ------------------------------------------------------------------  •
  344. ;•       Kevin McEntee   2/20/90         Original Implementation             •
  345. ;•                                                                           •
  346. ;•                                                                           •
  347. ;•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••*/
  348. SET_JUMP_TRACE_BIT            PROC
  349.                             Ori.w            #$4000,SR
  350.                             RTS
  351.                             ENDPROC
  352.                             
  353. CLEAR_JUMP_TRACE_BIT        PROC
  354.                                 Andi.w    #$BFFF,SR
  355.                                 RTS
  356.                                 ENDPROC
  357.                             
  358.                                 END
  359.